package com.ssy.lingxi.marketing.controller.coupon;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.marketing.model.vo.coupon.request.ActivityPageCouponDetailRequest;
import com.ssy.lingxi.marketing.model.vo.coupon.request.ActivityPageMerchantCouponRequest;
import com.ssy.lingxi.marketing.model.vo.coupon.response.ActivityPageCouponDetailResponse;
import com.ssy.lingxi.marketing.model.vo.coupon.response.ActivityPageCouponPageResponse;
import com.ssy.lingxi.marketing.service.IActivityPageCouponService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 *
 * @menu 平台活动页 - 优惠券
 * @author yzc
 * @version 2.0.0
 * @date 2021/6/28
 */
@RestController
@RequestMapping("/marketing/coupon/platform/activityPage")
public class PlatformCouponActivityPageController extends BaseController {

    @Resource
    private IActivityPageCouponService activityPageCouponService;

    /**
     * 平台营销活动页 - 选择平台优惠券
     * @return 返回结果
     */
    @RequestMapping(value = "/select/page", method = RequestMethod.GET)
    public Wrapper<PageData<ActivityPageCouponPageResponse>> pagePlatformActivityPagePlatformCoupon(@Valid ActivityPageMerchantCouponRequest request) {
        UserLoginCacheDTO loginUser = getPlatformUser();
        return activityPageCouponService.pagePlatformActivityPagePlatformCoupon(request, loginUser);
    }

    /**
     * 平台营销活动页 - 选择商家优惠券
     * @return 返回结果
     */
    @RequestMapping(value = "/select/merchant/page", method = RequestMethod.GET)
    public Wrapper<PageData<ActivityPageCouponPageResponse>> pagePlatformActivityPageMerchantCoupon(@Valid ActivityPageMerchantCouponRequest request) {
        UserLoginCacheDTO loginUser = getPlatformUser();
        return activityPageCouponService.pagePlatformActivityPageMerchantCoupon(request, loginUser);
    }

    /**
     * 平台活动页 - 优惠券详情
     * @return 返回结果
     */
    @RequestMapping(value = "/select/detail", method = RequestMethod.POST)
    public Wrapper<List<ActivityPageCouponDetailResponse>> listPlatformActivityPageCouponDetail(@RequestBody @Valid ActivityPageCouponDetailRequest request) {
        UserLoginCacheDTO loginUser = getPlatformUser();
        return activityPageCouponService.listPlatformActivityPageCouponDetail(request, loginUser);
    }
}
